#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10,L=1e6+10;
struct Node{
    int d,v,a;
}c[N];
struct node{
    int st,en;
}fi[N];
int T,n,m,l,V,p[N],ans1,ans2,cnt;
int cha[L],sum[L],ok[L];
bool f[L],vis[L];
bool cmp(node a,node b){
    if(a.en!=b.en)return a.en<b.en;
}
void init(){
    ans1=ans2=0;
    for(int i=1;i<L;i++){
        sum[i]=f[i]=cha[i]=ok[i]=0;
        vis[i]=0;
    }
    cnt=0;
}
int work1(int d,int v,int a){
    int lft=d,rgt=l,ans=-1;
    while(lft<=rgt){
        int mid=(rgt+lft)/2;
        int dis=mid-d;
        if(v*v+2*a*dis>V*V){
            ans=mid;
            rgt=mid-1;
        }
        else{
            lft=mid+1;
        }
    }
    return ans;
}
int work2(int d,int v,int a){
    int lft=d,rgt=l,ans=-1;
    while(lft<=rgt){
        int mid=(rgt+lft)/2;
        int dis=mid-d;
        if(v*v+2*a*dis>V*V){
            ans=mid;
            lft=mid+1;
        }
        else{
            rgt=mid-1;
        }
    }
    return ans;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        init();
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            sum[p[i]]=1;
            f[p[i]]=1;
        }
        for(int i=1;i<=l;i++){
            sum[i]+=sum[i-1];
        }
        int maxfront=-1;
        for(int i=1;i<=n;i++){
            if(c[i].a>0){
                int loc=work1(c[i].d,c[i].v,c[i].a);
                if(loc!=-1){
                    if(sum[l]!=sum[loc-1]){
                        ans1++;
                        maxfront=max(maxfront,loc);
                    }
                }
            }
            else if(c[i].a==0){
                if(c[i].v>V and c[i].d<=p[m]){
                    ans1++;
                    maxfront=max(maxfront,c[i].d);
                }
            }
            else if(c[i].a<0){
                int loc=work2(c[i].d,c[i].v,c[i].a);
                if(loc!=-1){
                    if(sum[c[i].d-1]!=sum[loc]){
                        ans1++;
                        cnt++;
                        fi[cnt].st=c[i].d;
                        fi[cnt].en=loc;
                    }
                }
            }
        }
        cout<<ans1<<" ";
        sort(fi+1,fi+cnt+1,cmp);
        int p=-1;
        for(int i=1;i<=cnt;i++){
            if(!vis[i]){
                for(int j=fi[i].en;j>=fi[i].st;j--){
                    if(f[j]){
                        ans2++;
                        p=j;
                        break;
                    }
                }
                for(int j=i;j<=cnt;j++){
                    if(fi[j].st<=p and fi[j].en>=p){
                        vis[j]=1;
                    }
                }
            }
        }
        if(p<maxfront)ans2++;
        cout<<m-ans2<<endl;
    }
    return 0;
}
